home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Programming / gcc-2.95.3-3 / info / g77.info-6 < prev    next >
Encoding:
GNU Info File  |  2001-07-15  |  50.4 KB  |  1,327 lines

  1. This is Info file f/g77.info, produced by Makeinfo version 1.68 from
  2. the input file ./f/g77.texi.
  3.  
  4. INFO-DIR-SECTION Programming
  5. START-INFO-DIR-ENTRY
  6. * g77: (g77).                  The GNU Fortran compiler.
  7. END-INFO-DIR-ENTRY
  8.    This file documents the use and the internals of the GNU Fortran
  9. (`g77') compiler.  It corresponds to the GCC-2.95 version of `g77'.
  10.  
  11.    Published by the Free Software Foundation 59 Temple Place - Suite 330
  12. Boston, MA 02111-1307 USA
  13.  
  14.    Copyright (C) 1995-1999 Free Software Foundation, Inc.
  15.  
  16.    Permission is granted to make and distribute verbatim copies of this
  17. manual provided the copyright notice and this permission notice are
  18. preserved on all copies.
  19.  
  20.    Permission is granted to copy and distribute modified versions of
  21. this manual under the conditions for verbatim copying, provided also
  22. that the sections entitled "GNU General Public License," "Funding for
  23. Free Software," and "Protect Your Freedom--Fight `Look And Feel'" are
  24. included exactly as in the original, and provided that the entire
  25. resulting derived work is distributed under the terms of a permission
  26. notice identical to this one.
  27.  
  28.    Permission is granted to copy and distribute translations of this
  29. manual into another language, under the above conditions for modified
  30. versions, except that the sections entitled "GNU General Public
  31. License," "Funding for Free Software," and "Protect Your Freedom--Fight
  32. `Look And Feel'", and this permission notice, may be included in
  33. translations approved by the Free Software Foundation instead of in the
  34. original English.
  35.  
  36.    Contributed by James Craig Burley (<craig@jcb-sc.com>).  Inspired by
  37. a first pass at translating `g77-0.5.16/f/DOC' that was contributed to
  38. Craig by David Ronis (<ronis@onsager.chem.mcgill.ca>).
  39.  
  40. 
  41. File: g77.info,  Node: INCLUDE,  Next: Cpp-style directives,  Prev: Order,  Up: Characters Lines Sequence
  42.  
  43. Including Source Text
  44. ---------------------
  45.  
  46.    Additional source text may be included in the processing of the
  47. source file via the `INCLUDE' directive:
  48.  
  49.      INCLUDE FILENAME
  50.  
  51. The source text to be included is identified by FILENAME, which is a
  52. literal GNU Fortran character constant.  The meaning and interpretation
  53. of FILENAME depends on the implementation, but typically is a filename.
  54.  
  55.    (`g77' treats it as a filename that it searches for in the current
  56. directory and/or directories specified via the `-I' command-line
  57. option.)
  58.  
  59.    The effect of the `INCLUDE' directive is as if the included text
  60. directly replaced the directive in the source file prior to
  61. interpretation of the program.  Included text may itself use `INCLUDE'.
  62. The depth of nested `INCLUDE' references depends on the implementation,
  63. but typically is a positive integer.
  64.  
  65.    This virtual replacement treats the statements and `INCLUDE'
  66. directives in the included text as syntactically distinct from those in
  67. the including text.
  68.  
  69.    Therefore, the first non-comment line of the included text must not
  70. be a continuation line.  The included text must therefore have, after
  71. the non-comment lines, either an initial line (statement), an `INCLUDE'
  72. directive, or nothing (the end of the included text).
  73.  
  74.    Similarly, the including text may end the `INCLUDE' directive with a
  75. semicolon or the end of the line, but it cannot follow an `INCLUDE'
  76. directive at the end of its line with a continuation line.  Thus, the
  77. last statement in an included text may not be continued.
  78.  
  79.    Any statements between two `INCLUDE' directives on the same line are
  80. treated as if they appeared in between the respective included texts.
  81. For example:
  82.  
  83.      INCLUDE 'A'; PRINT *, 'B'; INCLUDE 'C'; END PROGRAM
  84.  
  85. If the text included by `INCLUDE 'A'' constitutes a `PRINT *, 'A''
  86. statement and the text included by `INCLUDE 'C'' constitutes a `PRINT
  87. *, 'C'' statement, then the output of the above sample program would be
  88.  
  89.      A
  90.      B
  91.      C
  92.  
  93. (with suitable allowances for how an implementation defines its
  94. handling of output).
  95.  
  96.    Included text must not include itself directly or indirectly,
  97. regardless of whether the FILENAME used to reference the text is the
  98. same.
  99.  
  100.    Note that `INCLUDE' is *not* a statement.  As such, it is neither a
  101. non-executable or executable statement.  However, if the text it
  102. includes constitutes one or more executable statements, then the
  103. placement of `INCLUDE' is subject to effectively the same restrictions
  104. as those on executable statements.
  105.  
  106.    An `INCLUDE' directive may be continued across multiple lines as if
  107. it were a statement.  This permits long names to be used for FILENAME.
  108.  
  109. 
  110. File: g77.info,  Node: Cpp-style directives,  Prev: INCLUDE,  Up: Characters Lines Sequence
  111.  
  112. Cpp-style directives
  113. --------------------
  114.  
  115.    `cpp' output-style `#' directives (*note C Preprocessor Output:
  116. (cpp)C Preprocessor Output.)  are recognized by the compiler even when
  117. the preprocessor isn't run on the input (as it is when compiling `.F'
  118. files).  (Note the distinction between these `cpp' `#' *output*
  119. directives and `#line' *input* directives.)
  120.  
  121. 
  122. File: g77.info,  Node: Data Types and Constants,  Next: Expressions,  Prev: Characters Lines Sequence,  Up: Language
  123.  
  124. Data Types and Constants
  125. ========================
  126.  
  127.    (The following information augments or overrides the information in
  128. Chapter 4 of ANSI X3.9-1978 FORTRAN 77 in specifying the GNU Fortran
  129. language.  Chapter 4 of that document otherwise serves as the basis for
  130. the relevant aspects of GNU Fortran.)
  131.  
  132.    To more concisely express the appropriate types for entities, this
  133. document uses the more concise Fortran 90 nomenclature such as
  134. `INTEGER(KIND=1)' instead of the more traditional, but less portably
  135. concise, byte-size-based nomenclature such as `INTEGER*4', wherever
  136. reasonable.
  137.  
  138.    When referring to generic types--in contexts where the specific
  139. precision and range of a type are not important--this document uses the
  140. generic type names `INTEGER', `LOGICAL', `REAL', `COMPLEX', and
  141. `CHARACTER'.
  142.  
  143.    In some cases, the context requires specification of a particular
  144. type.  This document uses the `KIND=' notation to accomplish this
  145. throughout, sometimes supplying the more traditional notation for
  146. clarification, though the traditional notation might not work the same
  147. way on all GNU Fortran implementations.
  148.  
  149.    Use of `KIND=' makes this document more concise because `g77' is
  150. able to define values for `KIND=' that have the same meanings on all
  151. systems, due to the way the Fortran 90 standard specifies these values
  152. are to be used.
  153.  
  154.    (In particular, that standard permits an implementation to
  155. arbitrarily assign nonnegative values.  There are four distinct sets of
  156. assignments: one to the `CHARACTER' type; one to the `INTEGER' type;
  157. one to the `LOGICAL' type; and the fourth to both the `REAL' and
  158. `COMPLEX' types.  Implementations are free to assign these values in
  159. any order, leave gaps in the ordering of assignments, and assign more
  160. than one value to a representation.)
  161.  
  162.    This makes `KIND=' values superior to the values used in
  163. non-standard statements such as `INTEGER*4', because the meanings of
  164. the values in those statements vary from machine to machine, compiler
  165. to compiler, even operating system to operating system.
  166.  
  167.    However, use of `KIND=' is *not* generally recommended when writing
  168. portable code (unless, for example, the code is going to be compiled
  169. only via `g77', which is a widely ported compiler).  GNU Fortran does
  170. not yet have adequate language constructs to permit use of `KIND=' in a
  171. fashion that would make the code portable to Fortran 90
  172. implementations; and, this construct is known to *not* be accepted by
  173. many popular FORTRAN 77 implementations, so it cannot be used in code
  174. that is to be ported to those.
  175.  
  176.    The distinction here is that this document is able to use specific
  177. values for `KIND=' to concisely document the types of various
  178. operations and operands.
  179.  
  180.    A Fortran program should use the FORTRAN 77 designations for the
  181. appropriate GNU Fortran types--such as `INTEGER' for `INTEGER(KIND=1)',
  182. `REAL' for `REAL(KIND=1)', and `DOUBLE COMPLEX' for
  183. `COMPLEX(KIND=2)'--and, where no such designations exist, make use of
  184. appropriate techniques (preprocessor macros, parameters, and so on) to
  185. specify the types in a fashion that may be easily adjusted to suit each
  186. particular implementation to which the program is ported.  (These types
  187. generally won't need to be adjusted for ports of `g77'.)
  188.  
  189.    Further details regarding GNU Fortran data types and constants are
  190. provided below.
  191.  
  192. * Menu:
  193.  
  194. * Types::
  195. * Constants::
  196. * Integer Type::
  197. * Character Type::
  198.  
  199. 
  200. File: g77.info,  Node: Types,  Next: Constants,  Up: Data Types and Constants
  201.  
  202. Data Types
  203. ----------
  204.  
  205.    (Corresponds to Section 4.1 of ANSI X3.9-1978 FORTRAN 77.)
  206.  
  207.    GNU Fortran supports these types:
  208.  
  209.   1. Integer (generic type `INTEGER')
  210.  
  211.   2. Real (generic type `REAL')
  212.  
  213.   3. Double precision
  214.  
  215.   4. Complex (generic type `COMPLEX')
  216.  
  217.   5. Logical (generic type `LOGICAL')
  218.  
  219.   6. Character (generic type `CHARACTER')
  220.  
  221.   7. Double Complex
  222.  
  223.    (The types numbered 1 through 6 above are standard FORTRAN 77 types.)
  224.  
  225.    The generic types shown above are referred to in this document using
  226. only their generic type names.  Such references usually indicate that
  227. any specific type (kind) of that generic type is valid.
  228.  
  229.    For example, a context described in this document as accepting the
  230. `COMPLEX' type also is likely to accept the `DOUBLE COMPLEX' type.
  231.  
  232.    The GNU Fortran language supports three ways to specify a specific
  233. kind of a generic type.
  234.  
  235. * Menu:
  236.  
  237. * Double Notation::  As in `DOUBLE COMPLEX'.
  238. * Star Notation::    As in `INTEGER*4'.
  239. * Kind Notation::    As in `INTEGER(KIND=1)'.
  240.  
  241. 
  242. File: g77.info,  Node: Double Notation,  Next: Star Notation,  Up: Types
  243.  
  244. Double Notation
  245. ...............
  246.  
  247.    The GNU Fortran language supports two uses of the keyword `DOUBLE'
  248. to specify a specific kind of type:
  249.  
  250.    * `DOUBLE PRECISION', equivalent to `REAL(KIND=2)'
  251.  
  252.    * `DOUBLE COMPLEX', equivalent to `COMPLEX(KIND=2)'
  253.  
  254.    Use one of the above forms where a type name is valid.
  255.  
  256.    While use of this notation is popular, it doesn't scale well in a
  257. language or dialect rich in intrinsic types, as is the case for the GNU
  258. Fortran language (especially planned future versions of it).
  259.  
  260.    After all, one rarely sees type names such as `DOUBLE INTEGER',
  261. `QUADRUPLE REAL', or `QUARTER INTEGER'.  Instead, `INTEGER*8',
  262. `REAL*16', and `INTEGER*1' often are substituted for these,
  263. respectively, even though they do not always have the same meanings on
  264. all systems.  (And, the fact that `DOUBLE REAL' does not exist as such
  265. is an inconsistency.)
  266.  
  267.    Therefore, this document uses "double notation" only on occasion for
  268. the benefit of those readers who are accustomed to it.
  269.  
  270. 
  271. File: g77.info,  Node: Star Notation,  Next: Kind Notation,  Prev: Double Notation,  Up: Types
  272.  
  273. Star Notation
  274. .............
  275.  
  276.    The following notation specifies the storage size for a type:
  277.  
  278.      GENERIC-TYPE*N
  279.  
  280. GENERIC-TYPE must be a generic type--one of `INTEGER', `REAL',
  281. `COMPLEX', `LOGICAL', or `CHARACTER'.  N must be one or more digits
  282. comprising a decimal integer number greater than zero.
  283.  
  284.    Use the above form where a type name is valid.
  285.  
  286.    The `*N' notation specifies that the amount of storage occupied by
  287. variables and array elements of that type is N times the storage
  288. occupied by a `CHARACTER*1' variable.
  289.  
  290.    This notation might indicate a different degree of precision and/or
  291. range for such variables and array elements, and the functions that
  292. return values of types using this notation.  It does not limit the
  293. precision or range of values of that type in any particular way--use
  294. explicit code to do that.
  295.  
  296.    Further, the GNU Fortran language requires no particular values for
  297. N to be supported by an implementation via the `*N' notation.  `g77'
  298. supports `INTEGER*1' (as `INTEGER(KIND=3)') on all systems, for example,
  299. but not all implementations are required to do so, and `g77' is known
  300. to not support `REAL*1' on most (or all) systems.
  301.  
  302.    As a result, except for GENERIC-TYPE of `CHARACTER', uses of this
  303. notation should be limited to isolated portions of a program that are
  304. intended to handle system-specific tasks and are expected to be
  305. non-portable.
  306.  
  307.    (Standard FORTRAN 77 supports the `*N' notation for only
  308. `CHARACTER', where it signifies not only the amount of storage
  309. occupied, but the number of characters in entities of that type.
  310. However, almost all Fortran compilers have supported this notation for
  311. generic types, though with a variety of meanings for N.)
  312.  
  313.    Specifications of types using the `*N' notation always are
  314. interpreted as specifications of the appropriate types described in
  315. this document using the `KIND=N' notation, described below.
  316.  
  317.    While use of this notation is popular, it doesn't serve well in the
  318. context of a widely portable dialect of Fortran, such as the GNU
  319. Fortran language.
  320.  
  321.    For example, even on one particular machine, two or more popular
  322. Fortran compilers might well disagree on the size of a type declared
  323. `INTEGER*2' or `REAL*16'.  Certainly there is known to be disagreement
  324. over such things among Fortran compilers on *different* systems.
  325.  
  326.    Further, this notation offers no elegant way to specify sizes that
  327. are not even multiples of the "byte size" typically designated by
  328. `INTEGER*1'.  Use of "absurd" values (such as `INTEGER*1000') would
  329. certainly be possible, but would perhaps be stretching the original
  330. intent of this notation beyond the breaking point in terms of
  331. widespread readability of documentation and code making use of it.
  332.  
  333.    Therefore, this document uses "star notation" only on occasion for
  334. the benefit of those readers who are accustomed to it.
  335.  
  336. 
  337. File: g77.info,  Node: Kind Notation,  Prev: Star Notation,  Up: Types
  338.  
  339. Kind Notation
  340. .............
  341.  
  342.    The following notation specifies the kind-type selector of a type:
  343.  
  344.      GENERIC-TYPE(KIND=N)
  345.  
  346. Use the above form where a type name is valid.
  347.  
  348.    GENERIC-TYPE must be a generic type--one of `INTEGER', `REAL',
  349. `COMPLEX', `LOGICAL', or `CHARACTER'.  N must be an integer
  350. initialization expression that is a positive, nonzero value.
  351.  
  352.    Programmers are discouraged from writing these values directly into
  353. their code.  Future versions of the GNU Fortran language will offer
  354. facilities that will make the writing of code portable to `g77' *and*
  355. Fortran 90 implementations simpler.
  356.  
  357.    However, writing code that ports to existing FORTRAN 77
  358. implementations depends on avoiding the `KIND=' construct.
  359.  
  360.    The `KIND=' construct is thus useful in the context of GNU Fortran
  361. for two reasons:
  362.  
  363.    * It provides a means to specify a type in a fashion that is
  364.      portable across all GNU Fortran implementations (though not other
  365.      FORTRAN 77 and Fortran 90 implementations).
  366.  
  367.    * It provides a sort of Rosetta stone for this document to use to
  368.      concisely describe the types of various operations and operands.
  369.  
  370.    The values of N in the GNU Fortran language are assigned using a
  371. scheme that:
  372.  
  373.    * Attempts to maximize the ability of readers of this document to
  374.      quickly familiarize themselves with assignments for popular types
  375.  
  376.    * Provides a unique value for each specific desired meaning
  377.  
  378.    * Provides a means to automatically assign new values so they have a
  379.      "natural" relationship to existing values, if appropriate, or, if
  380.      no such relationship exists, will not interfere with future values
  381.      assigned on the basis of such relationships
  382.  
  383.    * Avoids using values that are similar to values used in the
  384.      existing, popular `*N' notation, to prevent readers from expecting
  385.      that these implied correspondences work on all GNU Fortran
  386.      implementations
  387.  
  388.    The assignment system accomplishes this by assigning to each
  389. "fundamental meaning" of a specific type a unique prime number.
  390. Combinations of fundamental meanings--for example, a type that is two
  391. times the size of some other type--are assigned values of N that are
  392. the products of the values for those fundamental meanings.
  393.  
  394.    A prime value of N is never given more than one fundamental meaning,
  395. to avoid situations where some code or system cannot reasonably provide
  396. those meanings in the form of a single type.
  397.  
  398.    The values of N assigned so far are:
  399.  
  400. `KIND=0'
  401.      This value is reserved for future use.
  402.  
  403.      The planned future use is for this value to designate, explicitly,
  404.      context-sensitive kind-type selection.  For example, the
  405.      expression `1D0 * 0.1_0' would be equivalent to `1D0 * 0.1D0'.
  406.  
  407. `KIND=1'
  408.      This corresponds to the default types for `REAL', `INTEGER',
  409.      `LOGICAL', `COMPLEX', and `CHARACTER', as appropriate.
  410.  
  411.      These are the "default" types described in the Fortran 90 standard,
  412.      though that standard does not assign any particular `KIND=' value
  413.      to these types.
  414.  
  415.      (Typically, these are `REAL*4', `INTEGER*4', `LOGICAL*4', and
  416.      `COMPLEX*8'.)
  417.  
  418. `KIND=2'
  419.      This corresponds to types that occupy twice as much storage as the
  420.      default types.  `REAL(KIND=2)' is `DOUBLE PRECISION' (typically
  421.      `REAL*8'), `COMPLEX(KIND=2)' is `DOUBLE COMPLEX' (typically
  422.      `COMPLEX*16'),
  423.  
  424.      These are the "double precision" types described in the Fortran 90
  425.      standard, though that standard does not assign any particular
  426.      `KIND=' value to these types.
  427.  
  428.      N of 4 thus corresponds to types that occupy four times as much
  429.      storage as the default types, N of 8 to types that occupy eight
  430.      times as much storage, and so on.
  431.  
  432.      The `INTEGER(KIND=2)' and `LOGICAL(KIND=2)' types are not
  433.      necessarily supported by every GNU Fortran implementation.
  434.  
  435. `KIND=3'
  436.      This corresponds to types that occupy as much storage as the
  437.      default `CHARACTER' type, which is the same effective type as
  438.      `CHARACTER(KIND=1)' (making that type effectively the same as
  439.      `CHARACTER(KIND=3)').
  440.  
  441.      (Typically, these are `INTEGER*1' and `LOGICAL*1'.)
  442.  
  443.      N of 6 thus corresponds to types that occupy twice as much storage
  444.      as the N=3 types, N of 12 to types that occupy four times as much
  445.      storage, and so on.
  446.  
  447.      These are not necessarily supported by every GNU Fortran
  448.      implementation.
  449.  
  450. `KIND=5'
  451.      This corresponds to types that occupy half the storage as the
  452.      default (N=1) types.
  453.  
  454.      (Typically, these are `INTEGER*2' and `LOGICAL*2'.)
  455.  
  456.      N of 25 thus corresponds to types that occupy one-quarter as much
  457.      storage as the default types.
  458.  
  459.      These are not necessarily supported by every GNU Fortran
  460.      implementation.
  461.  
  462. `KIND=7'
  463.      This is valid only as `INTEGER(KIND=7)' and denotes the `INTEGER'
  464.      type that has the smallest storage size that holds a pointer on
  465.      the system.
  466.  
  467.      A pointer representable by this type is capable of uniquely
  468.      addressing a `CHARACTER*1' variable, array, array element, or
  469.      substring.
  470.  
  471.      (Typically this is equivalent to `INTEGER*4' or, on 64-bit
  472.      systems, `INTEGER*8'.  In a compatible C implementation, it
  473.      typically would be the same size and semantics of the C type `void
  474.      *'.)
  475.  
  476.    Note that these are *proposed* correspondences and might change in
  477. future versions of `g77'--avoid writing code depending on them while
  478. `g77', and therefore the GNU Fortran language it defines, is in beta
  479. testing.
  480.  
  481.    Values not specified in the above list are reserved to future
  482. versions of the GNU Fortran language.
  483.  
  484.    Implementation-dependent meanings will be assigned new, unique prime
  485. numbers so as to not interfere with other implementation-dependent
  486. meanings, and offer the possibility of increasing the portability of
  487. code depending on such types by offering support for them in other GNU
  488. Fortran implementations.
  489.  
  490.    Other meanings that might be given unique values are:
  491.  
  492.    * Types that make use of only half their storage size for
  493.      representing precision and range.
  494.  
  495.      For example, some compilers offer options that cause `INTEGER'
  496.      types to occupy the amount of storage that would be needed for
  497.      `INTEGER(KIND=2)' types, but the range remains that of
  498.      `INTEGER(KIND=1)'.
  499.  
  500.    * The IEEE single floating-point type.
  501.  
  502.    * Types with a specific bit pattern (endianness), such as the
  503.      little-endian form of `INTEGER(KIND=1)'.  These could permit,
  504.      conceptually, use of portable code and implementations on data
  505.      files written by existing systems.
  506.  
  507.    Future *prime* numbers should be given meanings in as incremental a
  508. fashion as possible, to allow for flexibility and expressiveness in
  509. combining types.
  510.  
  511.    For example, instead of defining a prime number for little-endian
  512. IEEE doubles, one prime number might be assigned the meaning
  513. "little-endian", another the meaning "IEEE double", and the value of N
  514. for a little-endian IEEE double would thus naturally be the product of
  515. those two respective assigned values.  (It could even be reasonable to
  516. have IEEE values result from the products of prime values denoting
  517. exponent and fraction sizes and meanings, hidden bit usage,
  518. availability and representations of special values such as subnormals,
  519. infinities, and Not-A-Numbers (NaNs), and so on.)
  520.  
  521.    This assignment mechanism, while not inherently required for future
  522. versions of the GNU Fortran language, is worth using because it could
  523. ease management of the "space" of supported types much easier in the
  524. long run.
  525.  
  526.    The above approach suggests a mechanism for specifying inheritance
  527. of intrinsic (built-in) types for an entire, widely portable product
  528. line.  It is certainly reasonable that, unlike programmers of other
  529. languages offering inheritance mechanisms that employ verbose names for
  530. classes and subclasses, along with graphical browsers to elucidate the
  531. relationships, Fortran programmers would employ a mechanism that works
  532. by multiplying prime numbers together and finding the prime factors of
  533. such products.
  534.  
  535.    Most of the advantages for the above scheme have been explained
  536. above.  One disadvantage is that it could lead to the defining, by the
  537. GNU Fortran language, of some fairly large prime numbers.  This could
  538. lead to the GNU Fortran language being declared "munitions" by the
  539. United States Department of Defense.
  540.  
  541. 
  542. File: g77.info,  Node: Constants,  Next: Integer Type,  Prev: Types,  Up: Data Types and Constants
  543.  
  544. Constants
  545. ---------
  546.  
  547.    (Corresponds to Section 4.2 of ANSI X3.9-1978 FORTRAN 77.)
  548.  
  549.    A "typeless constant" has one of the following forms:
  550.  
  551.      'BINARY-DIGITS'B
  552.      'OCTAL-DIGITS'O
  553.      'HEXADECIMAL-DIGITS'Z
  554.      'HEXADECIMAL-DIGITS'X
  555.  
  556. BINARY-DIGITS, OCTAL-DIGITS, and HEXADECIMAL-DIGITS are nonempty
  557. strings of characters in the set `01', `01234567', and
  558. `0123456789ABCDEFabcdef', respectively.  (The value for `A' (and `a')
  559. is 10, for `B' and `b' is 11, and so on.)
  560.  
  561.    A prefix-radix constant, such as `Z'ABCD'', can optionally be
  562. treated as typeless.  *Note Options Controlling Fortran Dialect:
  563. Fortran Dialect Options, for information on the `-ftypeless-boz' option.
  564.  
  565.    Typeless constants have values that depend on the context in which
  566. they are used.
  567.  
  568.    All other constants, called "typed constants", are
  569. interpreted--converted to internal form--according to their inherent
  570. type.  Thus, context is *never* a determining factor for the type, and
  571. hence the interpretation, of a typed constant.  (All constants in the
  572. ANSI FORTRAN 77 language are typed constants.)
  573.  
  574.    For example, `1' is always type `INTEGER(KIND=1)' in GNU Fortran
  575. (called default INTEGER in Fortran 90), `9.435784839284958' is always
  576. type `REAL(KIND=1)' (even if the additional precision specified is
  577. lost, and even when used in a `REAL(KIND=2)' context), `1E0' is always
  578. type `REAL(KIND=2)', and `1D0' is always type `REAL(KIND=2)'.
  579.  
  580. 
  581. File: g77.info,  Node: Integer Type,  Next: Character Type,  Prev: Constants,  Up: Data Types and Constants
  582.  
  583. Integer Type
  584. ------------
  585.  
  586.    (Corresponds to Section 4.3 of ANSI X3.9-1978 FORTRAN 77.)
  587.  
  588.    An integer constant also may have one of the following forms:
  589.  
  590.      B'BINARY-DIGITS'
  591.      O'OCTAL-DIGITS'
  592.      Z'HEXADECIMAL-DIGITS'
  593.      X'HEXADECIMAL-DIGITS'
  594.  
  595. BINARY-DIGITS, OCTAL-DIGITS, and HEXADECIMAL-DIGITS are nonempty
  596. strings of characters in the set `01', `01234567', and
  597. `0123456789ABCDEFabcdef', respectively.  (The value for `A' (and `a')
  598. is 10, for `B' and `b' is 11, and so on.)
  599.  
  600. 
  601. File: g77.info,  Node: Character Type,  Prev: Integer Type,  Up: Data Types and Constants
  602.  
  603. Character Type
  604. --------------
  605.  
  606.    (Corresponds to Section 4.8 of ANSI X3.9-1978 FORTRAN 77.)
  607.  
  608.    A character constant may be delimited by a pair of double quotes
  609. (`"') instead of apostrophes.  In this case, an apostrophe within the
  610. constant represents a single apostrophe, while a double quote is
  611. represented in the source text of the constant by two consecutive double
  612. quotes with no intervening spaces.
  613.  
  614.    A character constant may be empty (have a length of zero).
  615.  
  616.    A character constant may include a substring specification, The
  617. value of such a constant is the value of the substring--for example,
  618. the value of `'hello'(3:5)' is the same as the value of `'llo''.
  619.  
  620. 
  621. File: g77.info,  Node: Expressions,  Next: Specification Statements,  Prev: Data Types and Constants,  Up: Language
  622.  
  623. Expressions
  624. ===========
  625.  
  626.    (The following information augments or overrides the information in
  627. Chapter 6 of ANSI X3.9-1978 FORTRAN 77 in specifying the GNU Fortran
  628. language.  Chapter 6 of that document otherwise serves as the basis for
  629. the relevant aspects of GNU Fortran.)
  630.  
  631. * Menu:
  632.  
  633. * %LOC()::
  634.  
  635. 
  636. File: g77.info,  Node: %LOC(),  Up: Expressions
  637.  
  638. The `%LOC()' Construct
  639. ----------------------
  640.  
  641.      %LOC(ARG)
  642.  
  643.    The `%LOC()' construct is an expression that yields the value of the
  644. location of its argument, ARG, in memory.  The size of the type of the
  645. expression depends on the system--typically, it is equivalent to either
  646. `INTEGER(KIND=1)' or `INTEGER(KIND=2)', though it is actually type
  647. `INTEGER(KIND=7)'.
  648.  
  649.    The argument to `%LOC()' must be suitable as the left-hand side of
  650. an assignment statement.  That is, it may not be a general expression
  651. involving operators such as addition, subtraction, and so on, nor may
  652. it be a constant.
  653.  
  654.    Use of `%LOC()' is recommended only for code that is accessing
  655. facilities outside of GNU Fortran, such as operating system or
  656. windowing facilities.  It is best to constrain such uses to isolated
  657. portions of a program--portions that deal specifically and exclusively
  658. with low-level, system-dependent facilities.  Such portions might well
  659. provide a portable interface for use by the program as a whole, but are
  660. themselves not portable, and should be thoroughly tested each time they
  661. are rebuilt using a new compiler or version of a compiler.
  662.  
  663.    Do not depend on `%LOC()' returning a pointer that can be safely
  664. used to *define* (change) the argument.  While this might work in some
  665. circumstances, it is hard to predict whether it will continue to work
  666. when a program (that works using this unsafe behavior) is recompiled
  667. using different command-line options or a different version of `g77'.
  668.  
  669.    Generally, `%LOC()' is safe when used as an argument to a procedure
  670. that makes use of the value of the corresponding dummy argument only
  671. during its activation, and only when such use is restricted to
  672. referencing (reading) the value of the argument to `%LOC()'.
  673.  
  674.    *Implementation Note:* Currently, `g77' passes arguments (those not
  675. passed using a construct such as `%VAL()') by reference or descriptor,
  676. depending on the type of the actual argument.  Thus, given `INTEGER I',
  677. `CALL FOO(I)' would seem to mean the same thing as `CALL
  678. FOO(%VAL(%LOC(I)))', and in fact might compile to identical code.
  679.  
  680.    However, `CALL FOO(%VAL(%LOC(I)))' emphatically means "pass, by
  681. value, the address of `I' in memory".  While `CALL FOO(I)' might use
  682. that same approach in a particular version of `g77', another version or
  683. compiler might choose a different implementation, such as
  684. copy-in/copy-out, to effect the desired behavior--and which will
  685. therefore not necessarily compile to the same code as would `CALL
  686. FOO(%VAL(%LOC(I)))' using the same version or compiler.
  687.  
  688.    *Note Debugging and Interfacing::, for detailed information on how
  689. this particular version of `g77' implements various constructs.
  690.  
  691. 
  692. File: g77.info,  Node: Specification Statements,  Next: Control Statements,  Prev: Expressions,  Up: Language
  693.  
  694. Specification Statements
  695. ========================
  696.  
  697.    (The following information augments or overrides the information in
  698. Chapter 8 of ANSI X3.9-1978 FORTRAN 77 in specifying the GNU Fortran
  699. language.  Chapter 8 of that document otherwise serves as the basis for
  700. the relevant aspects of GNU Fortran.)
  701.  
  702. * Menu:
  703.  
  704. * NAMELIST::
  705. * DOUBLE COMPLEX::
  706.  
  707. 
  708. File: g77.info,  Node: NAMELIST,  Next: DOUBLE COMPLEX,  Up: Specification Statements
  709.  
  710. `NAMELIST' Statement
  711. --------------------
  712.  
  713.    The `NAMELIST' statement, and related I/O constructs, are supported
  714. by the GNU Fortran language in essentially the same way as they are by
  715. `f2c'.
  716.  
  717.    This follows Fortran 90 with the restriction that on `NAMELIST'
  718. input, subscripts must have the form
  719.      SUBSCRIPT [ `:' SUBSCRIPT [ `:' STRIDE]]
  720.    i.e.
  721.      &xx x(1:3,8:10:2)=1,2,3,4,5,6/
  722.    is allowed, but not, say,
  723.      &xx x(:3,8::2)=1,2,3,4,5,6/
  724.  
  725.    As an extension of the Fortran 90 form, `$' and `$END' may be used
  726. in place of `&' and `/' in `NAMELIST' input, so that
  727.      $&xx x(1:3,8:10:2)=1,2,3,4,5,6 $end
  728.    could be used instead of the example above.
  729.  
  730. 
  731. File: g77.info,  Node: DOUBLE COMPLEX,  Prev: NAMELIST,  Up: Specification Statements
  732.  
  733. `DOUBLE COMPLEX' Statement
  734. --------------------------
  735.  
  736.    `DOUBLE COMPLEX' is a type-statement (and type) that specifies the
  737. type `COMPLEX(KIND=2)' in GNU Fortran.
  738.  
  739. 
  740. File: g77.info,  Node: Control Statements,  Next: Functions and Subroutines,  Prev: Specification Statements,  Up: Language
  741.  
  742. Control Statements
  743. ==================
  744.  
  745.    (The following information augments or overrides the information in
  746. Chapter 11 of ANSI X3.9-1978 FORTRAN 77 in specifying the GNU Fortran
  747. language.  Chapter 11 of that document otherwise serves as the basis
  748. for the relevant aspects of GNU Fortran.)
  749.  
  750. * Menu:
  751.  
  752. * DO WHILE::
  753. * END DO::
  754. * Construct Names::
  755. * CYCLE and EXIT::
  756.  
  757. 
  758. File: g77.info,  Node: DO WHILE,  Next: END DO,  Up: Control Statements
  759.  
  760. DO WHILE
  761. --------
  762.  
  763.    The `DO WHILE' statement, a feature of both the MIL-STD 1753 and
  764. Fortran 90 standards, is provided by the GNU Fortran language.  The
  765. Fortran 90 "do forever" statement comprising just `DO' is also
  766. supported.
  767.  
  768. 
  769. File: g77.info,  Node: END DO,  Next: Construct Names,  Prev: DO WHILE,  Up: Control Statements
  770.  
  771. END DO
  772. ------
  773.  
  774.    The `END DO' statement is provided by the GNU Fortran language.
  775.  
  776.    This statement is used in one of two ways:
  777.  
  778.    * The Fortran 90 meaning, in which it specifies the termination
  779.      point of a single `DO' loop started with a `DO' statement that
  780.      specifies no termination label.
  781.  
  782.    * The MIL-STD 1753 meaning, in which it specifies the termination
  783.      point of one or more `DO' loops, all of which start with a `DO'
  784.      statement that specify the label defined for the `END DO'
  785.      statement.
  786.  
  787.      This kind of `END DO' statement is merely a synonym for
  788.      `CONTINUE', except it is permitted only when the statement is
  789.      labeled and a target of one or more labeled `DO' loops.
  790.  
  791.      It is expected that this use of `END DO' will be removed from the
  792.      GNU Fortran language in the future, though it is likely that it
  793.      will long be supported by `g77' as a dialect form.
  794.  
  795. 
  796. File: g77.info,  Node: Construct Names,  Next: CYCLE and EXIT,  Prev: END DO,  Up: Control Statements
  797.  
  798. Construct Names
  799. ---------------
  800.  
  801.    The GNU Fortran language supports construct names as defined by the
  802. Fortran 90 standard.  These names are local to the program unit and are
  803. defined as follows:
  804.  
  805.      CONSTRUCT-NAME: BLOCK-STATEMENT
  806.  
  807. Here, CONSTRUCT-NAME is the construct name itself; its definition is
  808. connoted by the single colon (`:'); and BLOCK-STATEMENT is an `IF',
  809. `DO', or `SELECT CASE' statement that begins a block.
  810.  
  811.    A block that is given a construct name must also specify the same
  812. construct name in its termination statement:
  813.  
  814.      END BLOCK CONSTRUCT-NAME
  815.  
  816. Here, BLOCK must be `IF', `DO', or `SELECT', as appropriate.
  817.  
  818. 
  819. File: g77.info,  Node: CYCLE and EXIT,  Prev: Construct Names,  Up: Control Statements
  820.  
  821. The `CYCLE' and `EXIT' Statements
  822. ---------------------------------
  823.  
  824.    The `CYCLE' and `EXIT' statements specify that the remaining
  825. statements in the current iteration of a particular active (enclosing)
  826. `DO' loop are to be skipped.
  827.  
  828.    `CYCLE' specifies that these statements are skipped, but the `END
  829. DO' statement that marks the end of the `DO' loop be executed--that is,
  830. the next iteration, if any, is to be started.  If the statement marking
  831. the end of the `DO' loop is not `END DO'--in other words, if the loop
  832. is not a block `DO'--the `CYCLE' statement does not execute that
  833. statement, but does start the next iteration (if any).
  834.  
  835.    `EXIT' specifies that the loop specified by the `DO' construct is
  836. terminated.
  837.  
  838.    The `DO' loop affected by `CYCLE' and `EXIT' is the innermost
  839. enclosing `DO' loop when the following forms are used:
  840.  
  841.      CYCLE
  842.      EXIT
  843.  
  844.    Otherwise, the following forms specify the construct name of the
  845. pertinent `DO' loop:
  846.  
  847.      CYCLE CONSTRUCT-NAME
  848.      EXIT CONSTRUCT-NAME
  849.  
  850.    `CYCLE' and `EXIT' can be viewed as glorified `GO TO' statements.
  851. However, they cannot be easily thought of as `GO TO' statements in
  852. obscure cases involving FORTRAN 77 loops.  For example:
  853.  
  854.            DO 10 I = 1, 5
  855.            DO 10 J = 1, 5
  856.               IF (J .EQ. 5) EXIT
  857.            DO 10 K = 1, 5
  858.               IF (K .EQ. 3) CYCLE
  859.      10    PRINT *, 'I=', I, ' J=', J, ' K=', K
  860.      20    CONTINUE
  861.  
  862. In particular, neither the `EXIT' nor `CYCLE' statements above are
  863. equivalent to a `GO TO' statement to either label `10' or `20'.
  864.  
  865.    To understand the effect of `CYCLE' and `EXIT' in the above
  866. fragment, it is helpful to first translate it to its equivalent using
  867. only block `DO' loops:
  868.  
  869.            DO I = 1, 5
  870.               DO J = 1, 5
  871.                  IF (J .EQ. 5) EXIT
  872.                  DO K = 1, 5
  873.                     IF (K .EQ. 3) CYCLE
  874.      10             PRINT *, 'I=', I, ' J=', J, ' K=', K
  875.                  END DO
  876.               END DO
  877.            END DO
  878.      20    CONTINUE
  879.  
  880.    Adding new labels allows translation of `CYCLE' and `EXIT' to `GO
  881. TO' so they may be more easily understood by programmers accustomed to
  882. FORTRAN coding:
  883.  
  884.            DO I = 1, 5
  885.               DO J = 1, 5
  886.                  IF (J .EQ. 5) GOTO 18
  887.                  DO K = 1, 5
  888.                     IF (K .EQ. 3) GO TO 12
  889.      10             PRINT *, 'I=', I, ' J=', J, ' K=', K
  890.      12          END DO
  891.               END DO
  892.      18    END DO
  893.      20    CONTINUE
  894.  
  895. Thus, the `CYCLE' statement in the innermost loop skips over the
  896. `PRINT' statement as it begins the next iteration of the loop, while
  897. the `EXIT' statement in the middle loop ends that loop but *not* the
  898. outermost loop.
  899.  
  900. 
  901. File: g77.info,  Node: Functions and Subroutines,  Next: Scope and Classes of Names,  Prev: Control Statements,  Up: Language
  902.  
  903. Functions and Subroutines
  904. =========================
  905.  
  906.    (The following information augments or overrides the information in
  907. Chapter 15 of ANSI X3.9-1978 FORTRAN 77 in specifying the GNU Fortran
  908. language.  Chapter 15 of that document otherwise serves as the basis
  909. for the relevant aspects of GNU Fortran.)
  910.  
  911. * Menu:
  912.  
  913. * %VAL()::
  914. * %REF()::
  915. * %DESCR()::
  916. * Generics and Specifics::
  917. * REAL() and AIMAG() of Complex::
  918. * CMPLX() of DOUBLE PRECISION::
  919. * MIL-STD 1753::
  920. * f77/f2c Intrinsics::
  921. * Table of Intrinsic Functions::
  922.  
  923. 
  924. File: g77.info,  Node: %VAL(),  Next: %REF(),  Up: Functions and Subroutines
  925.  
  926. The `%VAL()' Construct
  927. ----------------------
  928.  
  929.      %VAL(ARG)
  930.  
  931.    The `%VAL()' construct specifies that an argument, ARG, is to be
  932. passed by value, instead of by reference or descriptor.
  933.  
  934.    `%VAL()' is restricted to actual arguments in invocations of
  935. external procedures.
  936.  
  937.    Use of `%VAL()' is recommended only for code that is accessing
  938. facilities outside of GNU Fortran, such as operating system or
  939. windowing facilities.  It is best to constrain such uses to isolated
  940. portions of a program--portions the deal specifically and exclusively
  941. with low-level, system-dependent facilities.  Such portions might well
  942. provide a portable interface for use by the program as a whole, but are
  943. themselves not portable, and should be thoroughly tested each time they
  944. are rebuilt using a new compiler or version of a compiler.
  945.  
  946.    *Implementation Note:* Currently, `g77' passes all arguments either
  947. by reference or by descriptor.
  948.  
  949.    Thus, use of `%VAL()' tends to be restricted to cases where the
  950. called procedure is written in a language other than Fortran that
  951. supports call-by-value semantics.  (C is an example of such a language.)
  952.  
  953.    *Note Procedures (SUBROUTINE and FUNCTION): Procedures, for detailed
  954. information on how this particular version of `g77' passes arguments to
  955. procedures.
  956.  
  957. 
  958. File: g77.info,  Node: %REF(),  Next: %DESCR(),  Prev: %VAL(),  Up: Functions and Subroutines
  959.  
  960. The `%REF()' Construct
  961. ----------------------
  962.  
  963.      %REF(ARG)
  964.  
  965.    The `%REF()' construct specifies that an argument, ARG, is to be
  966. passed by reference, instead of by value or descriptor.
  967.  
  968.    `%REF()' is restricted to actual arguments in invocations of
  969. external procedures.
  970.  
  971.    Use of `%REF()' is recommended only for code that is accessing
  972. facilities outside of GNU Fortran, such as operating system or
  973. windowing facilities.  It is best to constrain such uses to isolated
  974. portions of a program--portions the deal specifically and exclusively
  975. with low-level, system-dependent facilities.  Such portions might well
  976. provide a portable interface for use by the program as a whole, but are
  977. themselves not portable, and should be thoroughly tested each time they
  978. are rebuilt using a new compiler or version of a compiler.
  979.  
  980.    Do not depend on `%REF()' supplying a pointer to the procedure being
  981. invoked.  While that is a likely implementation choice, other
  982. implementation choices are available that preserve Fortran
  983. pass-by-reference semantics without passing a pointer to the argument,
  984. ARG.  (For example, a copy-in/copy-out implementation.)
  985.  
  986.    *Implementation Note:* Currently, `g77' passes all arguments (other
  987. than variables and arrays of type `CHARACTER') by reference.  Future
  988. versions of, or dialects supported by, `g77' might not pass `CHARACTER'
  989. functions by reference.
  990.  
  991.    Thus, use of `%REF()' tends to be restricted to cases where ARG is
  992. type `CHARACTER' but the called procedure accesses it via a means other
  993. than the method used for Fortran `CHARACTER' arguments.
  994.  
  995.    *Note Procedures (SUBROUTINE and FUNCTION): Procedures, for detailed
  996. information on how this particular version of `g77' passes arguments to
  997. procedures.
  998.  
  999. 
  1000. File: g77.info,  Node: %DESCR(),  Next: Generics and Specifics,  Prev: %REF(),  Up: Functions and Subroutines
  1001.  
  1002. The `%DESCR()' Construct
  1003. ------------------------
  1004.  
  1005.      %DESCR(ARG)
  1006.  
  1007.    The `%DESCR()' construct specifies that an argument, ARG, is to be
  1008. passed by descriptor, instead of by value or reference.
  1009.  
  1010.    `%DESCR()' is restricted to actual arguments in invocations of
  1011. external procedures.
  1012.  
  1013.    Use of `%DESCR()' is recommended only for code that is accessing
  1014. facilities outside of GNU Fortran, such as operating system or
  1015. windowing facilities.  It is best to constrain such uses to isolated
  1016. portions of a program--portions the deal specifically and exclusively
  1017. with low-level, system-dependent facilities.  Such portions might well
  1018. provide a portable interface for use by the program as a whole, but are
  1019. themselves not portable, and should be thoroughly tested each time they
  1020. are rebuilt using a new compiler or version of a compiler.
  1021.  
  1022.    Do not depend on `%DESCR()' supplying a pointer and/or a length
  1023. passed by value to the procedure being invoked.  While that is a likely
  1024. implementation choice, other implementation choices are available that
  1025. preserve the pass-by-reference semantics without passing a pointer to
  1026. the argument, ARG.  (For example, a copy-in/copy-out implementation.)
  1027. And, future versions of `g77' might change the way descriptors are
  1028. implemented, such as passing a single argument pointing to a record
  1029. containing the pointer/length information instead of passing that same
  1030. information via two arguments as it currently does.
  1031.  
  1032.    *Implementation Note:* Currently, `g77' passes all variables and
  1033. arrays of type `CHARACTER' by descriptor.  Future versions of, or
  1034. dialects supported by, `g77' might pass `CHARACTER' functions by
  1035. descriptor as well.
  1036.  
  1037.    Thus, use of `%DESCR()' tends to be restricted to cases where ARG is
  1038. not type `CHARACTER' but the called procedure accesses it via a means
  1039. similar to the method used for Fortran `CHARACTER' arguments.
  1040.  
  1041.    *Note Procedures (SUBROUTINE and FUNCTION): Procedures, for detailed
  1042. information on how this particular version of `g77' passes arguments to
  1043. procedures.
  1044.  
  1045. 
  1046. File: g77.info,  Node: Generics and Specifics,  Next: REAL() and AIMAG() of Complex,  Prev: %DESCR(),  Up: Functions and Subroutines
  1047.  
  1048. Generics and Specifics
  1049. ----------------------
  1050.  
  1051.    The ANSI FORTRAN 77 language defines generic and specific intrinsics.
  1052. In short, the distinctions are:
  1053.  
  1054.    * *Specific* intrinsics have specific types for their arguments and
  1055.      a specific return type.
  1056.  
  1057.    * *Generic* intrinsics are treated, on a case-by-case basis in the
  1058.      program's source code, as one of several possible specific
  1059.      intrinsics.
  1060.  
  1061.      Typically, a generic intrinsic has a return type that is
  1062.      determined by the type of one or more of its arguments.
  1063.  
  1064.    The GNU Fortran language generalizes these concepts somewhat,
  1065. especially by providing intrinsic subroutines and generic intrinsics
  1066. that are treated as either a specific intrinsic subroutine or a
  1067. specific intrinsic function (e.g. `SECOND').
  1068.  
  1069.    However, GNU Fortran avoids generalizing this concept to the point
  1070. where existing code would be accepted as meaning something possibly
  1071. different than what was intended.
  1072.  
  1073.    For example, `ABS' is a generic intrinsic, so all working code
  1074. written using `ABS' of an `INTEGER' argument expects an `INTEGER'
  1075. return value.  Similarly, all such code expects that `ABS' of an
  1076. `INTEGER*2' argument returns an `INTEGER*2' return value.
  1077.  
  1078.    Yet, `IABS' is a *specific* intrinsic that accepts only an
  1079. `INTEGER(KIND=1)' argument.  Code that passes something other than an
  1080. `INTEGER(KIND=1)' argument to `IABS' is not valid GNU Fortran code,
  1081. because it is not clear what the author intended.
  1082.  
  1083.    For example, if `J' is `INTEGER(KIND=6)', `IABS(J)' is not defined
  1084. by the GNU Fortran language, because the programmer might have used
  1085. that construct to mean any of the following, subtly different, things:
  1086.  
  1087.    * Convert `J' to `INTEGER(KIND=1)' first (as if `IABS(INT(J))' had
  1088.      been written).
  1089.  
  1090.    * Convert the result of the intrinsic to `INTEGER(KIND=1)' (as if
  1091.      `INT(ABS(J))' had been written).
  1092.  
  1093.    * No conversion (as if `ABS(J)' had been written).
  1094.  
  1095.    The distinctions matter especially when types and values wider than
  1096. `INTEGER(KIND=1)' (such as `INTEGER(KIND=2)'), or when operations
  1097. performing more "arithmetic" than absolute-value, are involved.
  1098.  
  1099.    The following sample program is not a valid GNU Fortran program, but
  1100. might be accepted by other compilers.  If so, the output is likely to
  1101. be revealing in terms of how a given compiler treats intrinsics (that
  1102. normally are specific) when they are given arguments that do not
  1103. conform to their stated requirements:
  1104.  
  1105.            PROGRAM JCB002
  1106.      C Version 1:
  1107.      C Modified 1999-02-15 (Burley) to delete my email address.
  1108.      C Modified 1997-05-21 (Burley) to accommodate compilers that implement
  1109.      C INT(I1-I2) as INT(I1)-INT(I2) given INTEGER*2 I1,I2.
  1110.      C
  1111.      C Version 0:
  1112.      C Written by James Craig Burley 1997-02-20.
  1113.      C
  1114.      C Purpose:
  1115.      C Determine how compilers handle non-standard IDIM
  1116.      C on INTEGER*2 operands, which presumably can be
  1117.      C extrapolated into understanding how the compiler
  1118.      C generally treats specific intrinsics that are passed
  1119.      C arguments not of the correct types.
  1120.      C
  1121.      C If your compiler implements INTEGER*2 and INTEGER
  1122.      C as the same type, change all INTEGER*2 below to
  1123.      C INTEGER*1.
  1124.      C
  1125.            INTEGER*2 I0, I4
  1126.            INTEGER I1, I2, I3
  1127.            INTEGER*2 ISMALL, ILARGE
  1128.            INTEGER*2 ITOOLG, ITWO
  1129.            INTEGER*2 ITMP
  1130.            LOGICAL L2, L3, L4
  1131.      C
  1132.      C Find smallest INTEGER*2 number.
  1133.      C
  1134.            ISMALL=0
  1135.       10   I0 = ISMALL-1
  1136.            IF ((I0 .GE. ISMALL) .OR. (I0+1 .NE. ISMALL)) GOTO 20
  1137.            ISMALL = I0
  1138.            GOTO 10
  1139.       20   CONTINUE
  1140.      C
  1141.      C Find largest INTEGER*2 number.
  1142.      C
  1143.            ILARGE=0
  1144.       30   I0 = ILARGE+1
  1145.            IF ((I0 .LE. ILARGE) .OR. (I0-1 .NE. ILARGE)) GOTO 40
  1146.            ILARGE = I0
  1147.            GOTO 30
  1148.       40   CONTINUE
  1149.      C
  1150.      C Multiplying by two adds stress to the situation.
  1151.      C
  1152.            ITWO = 2
  1153.      C
  1154.      C Need a number that, added to -2, is too wide to fit in I*2.
  1155.      C
  1156.            ITOOLG = ISMALL
  1157.      C
  1158.      C Use IDIM the straightforward way.
  1159.      C
  1160.            I1 = IDIM (ILARGE, ISMALL) * ITWO + ITOOLG
  1161.      C
  1162.      C Calculate result for first interpretation.
  1163.      C
  1164.            I2 = (INT (ILARGE) - INT (ISMALL)) * ITWO + ITOOLG
  1165.      C
  1166.      C Calculate result for second interpretation.
  1167.      C
  1168.            ITMP = ILARGE - ISMALL
  1169.            I3 = (INT (ITMP)) * ITWO + ITOOLG
  1170.      C
  1171.      C Calculate result for third interpretation.
  1172.      C
  1173.            I4 = (ILARGE - ISMALL) * ITWO + ITOOLG
  1174.      C
  1175.      C Print results.
  1176.      C
  1177.            PRINT *, 'ILARGE=', ILARGE
  1178.            PRINT *, 'ITWO=', ITWO
  1179.            PRINT *, 'ITOOLG=', ITOOLG
  1180.            PRINT *, 'ISMALL=', ISMALL
  1181.            PRINT *, 'I1=', I1
  1182.            PRINT *, 'I2=', I2
  1183.            PRINT *, 'I3=', I3
  1184.            PRINT *, 'I4=', I4
  1185.            PRINT *
  1186.            L2 = (I1 .EQ. I2)
  1187.            L3 = (I1 .EQ. I3)
  1188.            L4 = (I1 .EQ. I4)
  1189.            IF (L2 .AND. .NOT.L3 .AND. .NOT.L4) THEN
  1190.               PRINT *, 'Interp 1: IDIM(I*2,I*2) => IDIM(INT(I*2),INT(I*2))'
  1191.               STOP
  1192.            END IF
  1193.            IF (L3 .AND. .NOT.L2 .AND. .NOT.L4) THEN
  1194.               PRINT *, 'Interp 2: IDIM(I*2,I*2) => INT(DIM(I*2,I*2))'
  1195.               STOP
  1196.            END IF
  1197.            IF (L4 .AND. .NOT.L2 .AND. .NOT.L3) THEN
  1198.               PRINT *, 'Interp 3: IDIM(I*2,I*2) => DIM(I*2,I*2)'
  1199.               STOP
  1200.            END IF
  1201.            PRINT *, 'Results need careful analysis.'
  1202.            END
  1203.  
  1204.    No future version of the GNU Fortran language will likely permit
  1205. specific intrinsic invocations with wrong-typed arguments (such as
  1206. `IDIM' in the above example), since it has been determined that
  1207. disagreements exist among many production compilers on the
  1208. interpretation of such invocations.  These disagreements strongly
  1209. suggest that Fortran programmers, and certainly existing Fortran
  1210. programs, disagree about the meaning of such invocations.
  1211.  
  1212.    The first version of `JCB002' didn't accommodate some compilers'
  1213. treatment of `INT(I1-I2)' where `I1' and `I2' are `INTEGER*2'.  In such
  1214. a case, these compilers apparently convert both operands to `INTEGER*4'
  1215. and then do an `INTEGER*4' subtraction, instead of doing an `INTEGER*2'
  1216. subtraction on the original values in `I1' and `I2'.
  1217.  
  1218.    However, the results of the careful analyses done on the outputs of
  1219. programs compiled by these various compilers show that they all
  1220. implement either `Interp 1' or `Interp 2' above.
  1221.  
  1222.    Specifically, it is believed that the new version of `JCB002' above
  1223. will confirm that:
  1224.  
  1225.    * Digital Semiconductor ("DEC") Alpha OSF/1, HP-UX 10.0.1, AIX 3.2.5
  1226.      `f77' compilers all implement `Interp 1'.
  1227.  
  1228.    * IRIX 5.3 `f77' compiler implements `Interp 2'.
  1229.  
  1230.    * Solaris 2.5, SunOS 4.1.3, DECstation ULTRIX 4.3, and IRIX 6.1
  1231.      `f77' compilers all implement `Interp 3'.
  1232.  
  1233.    If you get different results than the above for the stated
  1234. compilers, or have results for other compilers that might be worth
  1235. adding to the above list, please let us know the details (compiler
  1236. product, version, machine, results, and so on).
  1237.  
  1238. 
  1239. File: g77.info,  Node: REAL() and AIMAG() of Complex,  Next: CMPLX() of DOUBLE PRECISION,  Prev: Generics and Specifics,  Up: Functions and Subroutines
  1240.  
  1241. `REAL()' and `AIMAG()' of Complex
  1242. ---------------------------------
  1243.  
  1244.    The GNU Fortran language disallows `REAL(EXPR)' and `AIMAG(EXPR)',
  1245. where EXPR is any `COMPLEX' type other than `COMPLEX(KIND=1)', except
  1246. when they are used in the following way:
  1247.  
  1248.      REAL(REAL(EXPR))
  1249.      REAL(AIMAG(EXPR))
  1250.  
  1251. The above forms explicitly specify that the desired effect is to
  1252. convert the real or imaginary part of EXPR, which might be some `REAL'
  1253. type other than `REAL(KIND=1)', to type `REAL(KIND=1)', and have that
  1254. serve as the value of the expression.
  1255.  
  1256.    The GNU Fortran language offers clearly named intrinsics to extract
  1257. the real and imaginary parts of a complex entity without any conversion:
  1258.  
  1259.      REALPART(EXPR)
  1260.      IMAGPART(EXPR)
  1261.  
  1262.    To express the above using typical extended FORTRAN 77, use the
  1263. following constructs (when EXPR is `COMPLEX(KIND=2)'):
  1264.  
  1265.      DBLE(EXPR)
  1266.      DIMAG(EXPR)
  1267.  
  1268.    The FORTRAN 77 language offers no way to explicitly specify the real
  1269. and imaginary parts of a complex expression of arbitrary type,
  1270. apparently as a result of requiring support for only one `COMPLEX' type
  1271. (`COMPLEX(KIND=1)').  The concepts of converting an expression to type
  1272. `REAL(KIND=1)' and of extracting the real part of a complex expression
  1273. were thus "smooshed" by FORTRAN 77 into a single intrinsic, since they
  1274. happened to have the exact same effect in that language (due to having
  1275. only one `COMPLEX' type).
  1276.  
  1277.    *Note:* When `-ff90' is in effect, `g77' treats `REAL(EXPR)', where
  1278. EXPR is of type `COMPLEX', as `REALPART(EXPR)', whereas with
  1279. `-fugly-complex -fno-f90' in effect, it is treated as
  1280. `REAL(REALPART(EXPR))'.
  1281.  
  1282.    *Note Ugly Complex Part Extraction::, for more information.
  1283.  
  1284. 
  1285. File: g77.info,  Node: CMPLX() of DOUBLE PRECISION,  Next: MIL-STD 1753,  Prev: REAL() and AIMAG() of Complex,  Up: Functions and Subroutines
  1286.  
  1287. `CMPLX()' of `DOUBLE PRECISION'
  1288. -------------------------------
  1289.  
  1290.    In accordance with Fortran 90 and at least some (perhaps all) other
  1291. compilers, the GNU Fortran language defines `CMPLX()' as always
  1292. returning a result that is type `COMPLEX(KIND=1)'.
  1293.  
  1294.    This means `CMPLX(D1,D2)', where `D1' and `D2' are `REAL(KIND=2)'
  1295. (`DOUBLE PRECISION'), is treated as:
  1296.  
  1297.      CMPLX(SNGL(D1), SNGL(D2))
  1298.  
  1299.    (It was necessary for Fortran 90 to specify this behavior for
  1300. `DOUBLE PRECISION' arguments, since that is the behavior mandated by
  1301. FORTRAN 77.)
  1302.  
  1303.    The GNU Fortran language also provides the `DCMPLX()' intrinsic,
  1304. which is provided by some FORTRAN 77 compilers to construct a `DOUBLE
  1305. COMPLEX' entity from of `DOUBLE PRECISION' operands.  However, this
  1306. solution does not scale well when more `COMPLEX' types (having various
  1307. precisions and ranges) are offered by Fortran implementations.
  1308.  
  1309.    Fortran 90 extends the `CMPLX()' intrinsic by adding an extra
  1310. argument used to specify the desired kind of complex result.  However,
  1311. this solution is somewhat awkward to use, and `g77' currently does not
  1312. support it.
  1313.  
  1314.    The GNU Fortran language provides a simple way to build a complex
  1315. value out of two numbers, with the precise type of the value determined
  1316. by the types of the two numbers (via the usual type-promotion
  1317. mechanism):
  1318.  
  1319.      COMPLEX(REAL, IMAG)
  1320.  
  1321.    When REAL and IMAG are the same `REAL' types, `COMPLEX()' performs
  1322. no conversion other than to put them together to form a complex result
  1323. of the same (complex version of real) type.
  1324.  
  1325.    *Note Complex Intrinsic::, for more information.
  1326.  
  1327.